package com.dhl.cloud.core.service;


import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.dhl.cloud.core.dao.UserAndRoleMapper;
import com.dhl.cloud.core.entity.UserAndRole;

@Service
public class UserRoleService {
	@Autowired
	private UserAndRoleMapper userAndRoleMapper;
 
	public List<UserAndRole> selectByusername(String username) {
		return userAndRoleMapper.selectByusername(username);
	}
	
	//目前只能这样
	public boolean isTeacher(String username)
	{
		List<UserAndRole> list = selectByusername(username);
		for (UserAndRole r:list)
		{
			if (r.getRoleid() == 4)
			{
				return true;
			}
		}
		return false;
	}
	public boolean isAdmin(String username)
	{
		List<UserAndRole> list = selectByusername(username);
		for (UserAndRole r:list)
		{
			if (r.getRoleid() == 2)
			{
				return true;
			}
		}
		return false;
	}
}
